package com.example.tianxi.yuexiuhhpatient;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class ForPasswordActivity extends Activity implements View.OnClickListener {

    private static final int ALREADY_EXIST = 105;
    private EditText userTel;
    private Button pwback;
    private Button back;
    private String result;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_for_password);
        userTel = (EditText)findViewById(R.id.forpassword_tel);
        pwback = (Button)findViewById(R.id.forpassword_post);
        back = (Button)findViewById(R.id.forpassword_back);

        pwback.setOnClickListener(this);
        back.setOnClickListener(this);
    }
    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.forpassword_post:
//                if (userTel.getText().toString().trim().length()>0) {
//                    HttpUtil.findPwdHttpRequest(userTel.getText().toString().trim(), new HttpHandler(ForPasswordActivity.this) {
//
//                        @Override
//                        public void onSuccess(String msg) {
//                            // TODO Auto-generated method stub
//                            result = msg;
//                            //返回 success error unregistered
//                            if (result.equals("unregistered")) {
//                                String text = "您输入的手机号" + userTel.getText().toString().trim() + "未注册，不能找回密码，请确认手机号是否正确";
//                                Intent intent = new Intent(ForPasswordActivity.this, AlertDialog.class);
//                                Bundle bundle = new Bundle();
//                                bundle.putString("flag", "ForPasswordActivity");
//                                bundle.putBoolean("titleIsCancel", false);
//                                bundle.putString("title", "手机号未注册");
//                                bundle.putString("msg", text);
//                                bundle.putString("okText", "返回重新输入");
//                                bundle.putBoolean("cancel", false);
//                                intent.putExtras(bundle);
//                                startActivityForResult(intent, ALREADY_EXIST);
//                            } else {
//                                startActivity(new Intent(ForPasswordActivity.this, SendMsgActivity.class).putExtra("tel", userTel.getText().toString().trim()));
//                            }
//                        }
//                    });
//                } else {
//                    Toast.makeText(ForPasswordActivity.this, "请填入电话号码", Toast.LENGTH_SHORT).show();
//                }
                break;

            case R.id.forpassword_back:
                finish();
                break;

            default:
                break;
        }
    }
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        // TODO Auto-generated method stub
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK && requestCode == ALREADY_EXIST) {
            finish();
        }
    }

}

